package hu.mapro.gwtui.gxt.client.editor;

import hu.mapro.gwtui.gxt.client.fieldseditor.field.EditorFieldInterface;
import hu.mapro.gwtui.gxt.client.fieldseditor.field.Util;
import hu.mapro.model.impl.BuiltinTypeFieldVisitorBase;

import com.sencha.gxt.widget.core.client.form.NumberField;
import com.sencha.gxt.widget.core.client.form.NumberPropertyEditor.DoublePropertyEditor;
import com.sencha.gxt.widget.core.client.form.NumberPropertyEditor.IntegerPropertyEditor;
import com.sencha.gxt.widget.core.client.form.NumberPropertyEditor.LongPropertyEditor;
import com.sencha.gxt.widget.core.client.form.TextField;

public class BuiltinTypeCreateFieldVisitor extends BuiltinTypeFieldVisitorBase<EditorFieldInterface<?>> {

	@Override
	public EditorFieldInterface<?> defaultValue() {
		throw new RuntimeException("Field creator not defined!");
	}
	
	@Override
	public EditorFieldInterface<?> scalarString() {
		TextField field = new TextField();
		
		return Util.createValueEditorField(field);
	}
	
	@Override
	public EditorFieldInterface<?> scalarInteger() {
		NumberField<Integer> field = new NumberField<Integer>(new IntegerPropertyEditor());
		
		return Util.createValueEditorField(field);
	}
	
	@Override
	public EditorFieldInterface<?> scalarLong() {
		NumberField<Long> field = new NumberField<Long>(new LongPropertyEditor());
		
		return Util.createValueEditorField(field);
	}
	
	@Override
	public EditorFieldInterface<?> scalarDouble() {
		NumberField<Double> field = new NumberField<Double>(new DoublePropertyEditor());
		
		return Util.createValueEditorField(field);
	}

}
